package com.lishiots.cloud.datacenter.middleware.common;

import com.github.pagehelper.PageInfo;

import java.math.BigDecimal;

/**
 * Created by Chaofan at 2018-11-19 14:26
 * email:chaofan2685@qq.com
 **/
public class BuildResult {

    protected RestfulMessage mergeObject(Object data){
        RestfulMessage r=new RestfulMessage();
        r.setCode(ErrorConstant.SUCCESS);
        r.setMessage("SUCCESS");
        r.setData(data);
        return r;
    }

    protected Pagination handlePagination(PageInfo pageInfo){
        Pagination result = new Pagination<>();
        result.setCount(new BigDecimal(pageInfo.getTotal()).intValue());
        result.setCurrent_page(pageInfo.getPageNum());
        result.setPage_size(pageInfo.getPageSize());
        result.setTotal_page(pageInfo.getPages());
        result.setData(pageInfo.getList());
        return result ;
    }

}
